/*
 * $Id$
 *
 * Copyright (c) 1998-2008 John Morrison.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */


/*
 * UDPSetupDialog.java
 *
 * Created on 23 May 2004, 20:46
 */

package com.jbolo.gui.dialog;

/**
 *
 * @author  John Morrison
 */
public class UDPSetupDialog extends CentredDialog {
    
    /** Creates new form UDPSetupDialog */
    public UDPSetupDialog(java.awt.Frame parent, boolean modal) {
        super(parent, "UDP (Internet) Setup", modal);
        initComponents();
        setSize(425,450);
        
        txtMyPort.addKeyListener(new NumberTextFieldListener());
        txtPort.addKeyListener(new NumberTextFieldListener());
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        java.awt.Button button1;
        java.awt.Label label1;
        java.awt.Label label2;

        label1 = new java.awt.Label();
        label2 = new java.awt.Label();
        label3 = new java.awt.Label();
        label4 = new java.awt.Label();
        label5 = new java.awt.Label();
        textField1 = new java.awt.TextField();
        txtPort = new java.awt.TextField();
        txtMyPort = new java.awt.TextField();
        txtPlayerName = new java.awt.TextField();
        chkRemember = new java.awt.Checkbox();
        button1 = new java.awt.Button();

        setLayout(null);

        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        });

        label1.setText("To join an internet Bolo game, you must give the name (or IP address) of a host\nmachine running Bolo, and the UDP port number of the Bolo process on that\nmachine.");
        add(label1);
        label1.setBounds(10, 30, 380, 80);

        label2.setText("Machine Name (or IP Address): ");
        add(label2);
        label2.setBounds(10, 120, 178, 20);

        label3.setText("UDP port of Bolo on the server machine: ");
        add(label3);
        label3.setBounds(10, 160, 230, 20);

        label4.setText("UDP port for the Bolo on this machine:");
        add(label4);
        label4.setBounds(10, 190, 230, 20);

        label5.setText("Your player name for the game: ");
        add(label5);
        label5.setBounds(10, 220, 230, 20);

        textField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textField1ActionPerformed(evt);
            }
        });

        add(textField1);
        textField1.setBounds(190, 120, 200, 20);

        add(txtPort);
        txtPort.setBounds(240, 160, 150, 20);

        add(txtMyPort);
        txtMyPort.setBounds(240, 190, 150, 20);

        add(txtPlayerName);
        txtPlayerName.setBounds(240, 220, 150, 20);

        chkRemember.setLabel("Remember Player Name");
        add(chkRemember);
        chkRemember.setBounds(160, 250, 230, 20);

        button1.setLabel("Tracker Setup");
        button1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button1ActionPerformed(evt);
            }
        });

        add(button1);
        button1.setBounds(217, 280, 120, 24);

        pack();
    }//GEN-END:initComponents

    private void textField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textField1ActionPerformed
        // TODO add your handling code here:
        
    }//GEN-LAST:event_textField1ActionPerformed

    private void button1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button1ActionPerformed
        // TODO add your handling code here:
        TrackerSetupDialog tsd = new TrackerSetupDialog(this, true);
        tsd.centre();
        tsd.setVisible(true);
        tsd = null;
    }//GEN-LAST:event_button1ActionPerformed
    
    /** Closes the dialog */
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
        setVisible(false);
        dispose();
    }//GEN-LAST:event_closeDialog
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        new UDPSetupDialog(new java.awt.Frame(), true).show();
    }
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private java.awt.Checkbox chkRemember;
    private java.awt.Label label3;
    private java.awt.Label label4;
    private java.awt.Label label5;
    private java.awt.TextField textField1;
    private java.awt.TextField txtMyPort;
    private java.awt.TextField txtPlayerName;
    private java.awt.TextField txtPort;
    // End of variables declaration//GEN-END:variables
    
}
